
function jf(){
	
	
    var jfval = $.trim($("#member_amount").val());
	if(jfval == ''){
		alert('请输入金额');
		$('#sktd').hide();
		return false;
	} 
	kcjf="9999999999900.00";
	jfnum=jfval*100;
	if(kcjf>jfnum){
	$("#jf").text(jfval+"元可获得积分"+jfval*100);
	
	}else{
	$("#jf").text("不可操作，"+jfval+"元可获得积分");
	$("#member_amount").val(0)
	}
	$('#sktd').show();
}


$(function() {
    var key = getCookie('key');
    if (!key) {
        window.location.href = WapSiteUrl+'/tmpl/member/login.html';
        return;
    }
	if (getQueryString("key") != "") {
        var a = getQueryString("key");
        var e = getQueryString("username");
        addCookie("key", a);
        addCookie("username", e)
    } else {
        var a = getCookie("key")
    }
    if (a) {
        $.ajax({
            type: "post",
            url: ApiUrl + "/index.php?act=member_index",
            data: {
                key: a
            },
            dataType: "json",
            success: function(a) {
				$('#kc').html(a.datas.member_info.kucun_points);
			
			}
        })
    } else {
		
	}

 $.ajax({
        type: "get",
        url: ApiUrl + "/index.php?act=index&op=showmd",
        data: {
            key: key
        },
        dataType: "json",
        success: function(e) {
            if (e.code == 200) {
					var a = '<select id="user" name="user" class="select">';
					for (var o in e.datas.chain_list) {
						a += '<option value="' + e.datas.chain_list[o].chain_user + '">' + e.datas.chain_list[o].chain_name + "</option>"
					}
					a+='</select>';
					$("#bbox").append(a);
                   // $("#mobile").html(e.datas.mobile)
               
            }else{
				   $("#bbox").append(' <input type="text" id="user" name="user" class="inp" maxlength="100" placeholder="请输入门店帐号" oninput="writeClear($(this));" onFocus="writeClear($(this));"/>');
				
			}
        }
    });

    $.sValid.init({
        rules:{
            user:"required",
            pwd:"required",
            member_name:"required",
            member_amount:"required",
        },
        messages:{
            user:"请输入门店帐号",
            pwd:"请输入门店密码",
            member_name:"请输入会员帐号",
            member_amount:"请输入收款金额",
        },
        callback:function (eId,eMsg,eRules){
            if(eId.length >0){
                var errorHtml = "";
                $.map(eMsg,function (idx,item){
                    errorHtml += "<p>"+idx+"</p>";
                });
                errorTipsShow(errorHtml);
            }else{
                errorTipsHide();
            }
        }
    });

    $('#saveform').click(function(){
							  
        if (!$(this).parent().hasClass('ok')) {
            return false;
        }

        if($.sValid()){
            var user = $.trim($("#user").val());
            var member_name = $.trim($("#member_name").val());
            var pwd = $.trim($("#pwd").val());
            var member_amount = $.trim($("#member_amount").val());
            var member_shuming = $.trim($("#member_shuming").val());
            $.ajax({
                type:'post',
                url:ApiUrl+"/index.php?act=index&op=shoukuan",
                data:{
				key:key,
				user:user,
				pwd:pwd,
				member_name:member_name,
				member_amount:member_amount,
				member_shuming:member_shuming,
				},
                dataType:'json',
                success:function(e){
                    if(e.code == 200){
						//TipsShow('<p>您的提现申请已成功提交，请等待系统处理</p>');
					 //toPay(e.datas.pay_sn, "member_buy", "pdrecharge_pay");
                         errorTipsShow('<p>' + e.datas + '</p>');
						 
                    }else{
                      //  loadSeccode();
                        errorTipsShow('<p>' + e.datas.error + '</p>');
                    }
                }
            });
        }
    });
});
